﻿/*
    File name:          Log
    File type:          class
    Author:             Mads Skipper Pedersen 07299
    Creation date:      29-03-2011
    Last modified:      29-03-2011
    Last modified by:   Mads Skipper Pedersen 07299
    Description:        The class type of our log files
*/

using System;
using System.ComponentModel;

namespace i4pro_gruppe_d.Types
{
        public enum Codes{ Normal = 1,
                    Command,
                    Error,
                    Emergency };

    public enum DescriptionType
    {
        BrickFailed = 0,
        RobotStarted,
        Emergency,
        UserCommand
    } ;
    

    public class Log
    {
        public int LogType { get; set; }
        public string LogEntry { get; set; }
        public int BatchId { get; set; }
        public DateTime LogTime { get; set; }
    }

    public class EventLog : INotifyPropertyChanged
    {
        private const int numberOfLogentries = 4;
        private string[] logDescriptions = new string[numberOfLogentries]
                                          {
                                              "Could not dertemine brick type.",
                                              "Robot started.",
                                              "Emergency",
                                              "User: "
                                          };

        public string GetLogDescription(int number)
        {
            if(number < numberOfLogentries && number >= 0)
                return logDescriptions[number];
            else
            {
                return "No description.";
            }
        }

        public EventLog()
        {
            
        }

        public EventLog(string _logEntry, DateTime _logTime, int _logType)
        {
            LogEntry = _logEntry;
            LogTime = _logTime;
            LogType = _logType;
        }

        private string logEntry;
        public string LogEntry 
        { 
            get { return logEntry; }
            set
            {
                logEntry = value;
                InvokePropertyChanged("LogEntry");
            }
        }

        private DateTime logTime;
        public DateTime LogTime
        {
            get { return logTime; }
            set
            {
                logTime = value;
                InvokePropertyChanged("LogTime");
            }
        }

        private int logType;
        public int LogType
        {
            get { return logType; }
            set
            {
                logType = value;
                InvokePropertyChanged("LogType");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void InvokePropertyChanged(String propertyName)
        {
            PropertyChangedEventArgs e = new PropertyChangedEventArgs(propertyName);

            PropertyChangedEventHandler changed = PropertyChanged;

            if (changed != null) changed(this, e);
        }
    }
}
